/*!
 * GlobalJObject.cpp  0.4.0 / Nov 14, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
#include "GlobalJObject.h"

#include "JNIWrapper.h"

// GlobalJObject :: Public Constructor. ----------------------------------------

/*!
 * \brief Constructs new GlobalJObject object.
 *
 * \param env the JNIEnv pointer
 * \param obj the Java object
 */
GlobalJObject::GlobalJObject(JNIEnv *env, jobject obj)
{
  if (obj) {
    m_obj = JNIWrapper::newGlobalRef(env, obj);
    m_env = env;
  } else {
    m_obj = 0;
  }
}

// GlobalJObject :: Public Destructor. -----------------------------------------

/*!
 * \brief Destroys GlobalJObject object.
 */
GlobalJObject::~GlobalJObject()
{
  if (m_obj) {
    m_env->DeleteGlobalRef(m_obj);
  }
}

// GlobalJObject :: Private Constructor. ---------------------------------------

GlobalJObject::GlobalJObject(const GlobalJObject &)
{
  // copy constructor is disabled.
}
